package cachaframework;

import java.util.concurrent.locks.LockSupport;

public class Test {


    public static void main(String[] args) throws InterruptedException {
        new Thread(new RebuildCacheThread()).start();


        Thread t = new Thread(
                ()->{
                    System.out.println("周末要打游戏！");
                    LockSupport.park();
                    System.out.println("陪女朋友逛街逛街！");
                }
        );
        t.start();
        Thread.sleep(1000);
        LockSupport.unpark(t);
        System.out.println("女朋友叫着男票逛街逛街逛街！");


        long l = System.currentTimeMillis();
        Thread thread = Thread.currentThread();
        ProductInfo productInfo = new ProductInfo();
        productInfo.setId(123L);
        productInfo.setThread(thread);
        new RebuildCacheQueue().putProductInfo(productInfo);

        long l1 = System.currentTimeMillis();
        LockSupport.parkUntil(200);
        System.out.println("LockSupport耗时：" + (System.currentTimeMillis() - l1));

        System.out.println(productInfo.toString());
        System.out.println("耗时：" + (System.currentTimeMillis() - l));
    }
}
